package com.niuxiaofa.newlaw.Activity;

import androidx.recyclerview.widget.RecyclerView;

import com.niuxiaofa.newlaw.Base.BaseActivity;
import com.niuxiaofa.newlaw.Base.RefreshInterface;
import com.niuxiaofa.newlaw.Bean.NewListBean;
import com.niuxiaofa.newlaw.Network.WisdomLibraryPresenter;
import com.niuxiaofa.newlaw.R;
import com.niuxiaofa.newlaw.Tools.RecyclerViewHelp;
import com.niuxiaofa.newlaw.Tools.ToActivityUtil;
import com.niuxiaofa.newlaw.adapter.NewsAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;


/**
 *  咨询
 */
public class InfomationActivity extends BaseActivity implements WisdomLibraryPresenter.interface_newList, RefreshInterface.Refresh {


    @BindView(R.id.recyclerview)
    RecyclerView recyclerView;


    List<NewListBean.DataDTO> newsList=new ArrayList<>();
    NewsAdapter newsAdapter;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_infomation;
    }

    @Override
    protected void initData() {
        refreshinterface=new RefreshInterface(this);

        setTitle("晓法咨询");
        newsAdapter=new NewsAdapter(newsList, new NewsAdapter.Onclick() {
            @Override
            public void onclick(int c) {
                String[][] a=new String[][]{{"id",newsList.get(c).getId()}};
                ToActivityUtil.toNextActivity(InfomationDetailsActivity.class,a);
            }
        });
        WisdomLibraryPresenter.newList(this);

        RecyclerViewHelp.setRecycler(recyclerView,10).setAdapter(newsAdapter);


    }


    @Override
    public void getResponse(NewListBean u) {
        if (u.getCode()==1){
            newsList.addAll(u.getData());
            newsAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void refresh() {

    }

    @Override
    public void loadmore() {

    }
}
